package com.pat.miniloyalty;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserServiceFactory;

public class ClientServlet extends HttpServlet
{

	private final static Logger m_logger = Logger.getLogger(ClientServlet.class.getName());
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
	{

		User user = UserServiceFactory.getUserService().getCurrentUser();
		if( (user != null) /*&& (user.getEmail() == "proglamer@gmail.com") */)
		{
			resp.setContentType("text/html");
			resp.getWriter().println("Are you sure you want to delete?<br />");
			resp.getWriter().println("<form method='post' action='/clients'><input type='hidden' name='id' value='2' /><input type='submit' value='' /></form>");
		}else
		{
			m_logger.info("Sending user to login...");
			resp.sendRedirect(UserServiceFactory.getUserService().createLoginURL(req.getRequestURI()));
		}
		
	}
	
}
